Conversation
HMCLCore/src/main/java/org/jackhuang/hmcl/download/game/GameRemoteVersion.java
Outdated
Show resolved
Hide resolved
| return dateCompare; | ||
| } | ||
|
|
||
| return GameVersionNumber.asGameVersion(getSelfVersion()).compareTo(o.getSelfVersion()); |
There was a problem hiding this comment.
return GameVersionNumber.asGameVersion(getSelfVersion())
.compareTo(GameVersionNumber.asGameVersion(o.getSelfVersion()));
There was a problem hiding this comment.
直接 GameVersionNumber.compare(getSelfVersion(), o.getSelfVersion()) 就可以了
There was a problem hiding this comment.
直接
GameVersionNumber.compare(getSelfVersion(), o.getSelfVersion())就可以了
thanks❤️
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a deduplication issue in the game version list where versions with identical release dates were being incorrectly removed. The fix modifies the comparison logic to use version numbers as a secondary comparison criteria when release dates are equal.
- Modified the
compareTomethod inGameRemoteVersionto include version number comparison as a tiebreaker - Added import for
GameVersionNumberutility class to support the enhanced comparison logic
| int dateCompare = o.getReleaseDate().compareTo(getReleaseDate()); | ||
| if (dateCompare != 0) { | ||
| return dateCompare; | ||
| } | ||
|
|
||
| return GameVersionNumber.compare(getSelfVersion(), o.getSelfVersion()); |
There was a problem hiding this comment.
The method call o.getSelfVersion() assumes that the cast to GameRemoteVersion is safe, but the type check only verifies instanceof GameRemoteVersion. If o is not actually a GameRemoteVersion, this will cause a ClassCastException. Consider casting o to GameRemoteVersion explicitly after the instanceof check.
| int dateCompare = o.getReleaseDate().compareTo(getReleaseDate()); | |
| if (dateCompare != 0) { | |
| return dateCompare; | |
| } | |
| return GameVersionNumber.compare(getSelfVersion(), o.getSelfVersion()); | |
| GameRemoteVersion gameRemoteVersion = (GameRemoteVersion) o; | |
| int dateCompare = gameRemoteVersion.getReleaseDate().compareTo(getReleaseDate()); | |
| if (dateCompare != 0) { | |
| return dateCompare; | |
| } | |
| return GameVersionNumber.compare(getSelfVersion(), gameRemoteVersion.getSelfVersion()); |
Uh oh!
There was an error while loading. Please reload this page.